﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankSimulation
{
    public partial class SignUpPage : Form
    {
        string signUpId;
        string signUpPwd;
        public SignUpPage()
        {
            InitializeComponent();
        }

        private void signUpPageBtn_Click(object sender, EventArgs e)
        {
            //如果注册重复，提示注册失败
            if (GlobalVar.bank1.AccountIsExist(signUpIdTextBox.Text))
            {
                MessageBox.Show("此账户已被注册！");
            
            } 
            //储蓄账户
            else if (accountTypeComboBox.SelectedIndex == 0)
            {

                //创建储蓄账户,初始金额为100000
                GlobalVar.bank1.CreatAccount(signUpIdTextBox.Text, signUpPwdTexBox.Text, 100000);
                MessageBox.Show("注册储蓄成功！");
                DialogResult = DialogResult.OK;
            }
            //信用账户
            else if (accountTypeComboBox.SelectedIndex == 1)
            {
                //创建信用账户，初始金额为100000，信用额度为100000
                GlobalVar.bank1.CreatAccount(signUpIdTextBox.Text, signUpPwdTexBox.Text, 100000, 100000);
                MessageBox.Show("注册信用账户成功！");
                DialogResult = DialogResult.OK;
            }
        }

        private void SignUpPage_Load(object sender, EventArgs e)
        {
            accountTypeComboBox.SelectedIndex = 0;
        }

        private void signUpPwdVisibleCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (signUpPwdVisibleCheckBox.Checked == true)
            {
                signUpPwdTexBox.PasswordChar = '\0';
            }
            else
            {
                signUpPwdTexBox.PasswordChar = '*';
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
